#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2019/4/13  19:02
# @Author: 余浪人
# @email: yulangren520@gmail.com


from apps.models import db, BaseModel
from apps.setting import Config
from apps.lib.public import get_date


class System_Model(BaseModel):
    web_name = db.Column(db.String(255), default='TLCms内容管理系统', comment='站点名称')
    web_key = db.Column(db.String(255), default='TL_CMS系统,新闻发布,最简单,多线程,高并发的系统', comment='站点关键词')
    web_description = db.Column(db.Text, default='TLCms内容管理系统', comment='站点描述')
    web_all_key = db.Column(db.String(255), default='', comment='全局关键词')
    web_domain = db.Column(db.String(100), default=Config.HOST, comment='网站域名')
    web_logo = db.Column(db.String(255), default='', comment='网站logo')
    web_QrCode = db.Column(db.String(255), default='', comment='网站logo')
    web_record = db.Column(db.String(100), default='蜀ICP备10000号-1', comment='备案号')
    web_stat = db.Column(db.Text, default='', comment='统计代码')
    web_company = db.Column(db.String(255), default='TlCms内容管理系统', comment='公司/单位/团体名称')
    web_contact_adders = db.Column(db.String(255), default='', comment='联系地址')
    web_contact_tel = db.Column(db.String(255), default='', comment='联系电话')
    web_contact_qq = db.Column(db.String(255), default='1368419640', comment='联系QQ')
    web_contact_email = db.Column(db.String(255), default='1368419640@qq.com', comment='联系邮箱')
    web_message = db.Column(db.Text, default='', comment='留言提示')
    web_topBar = db.Column(db.String(255), default='TL_CMS专注内容管理系统,网络爬虫系统等web系统开发', comment='顶栏描述')
    web_on_off = db.Column(db.Integer, default=1, comment='站点开关| 0:停用  1:启用')

    def __repr__(self):
        return f'站点名称: {self.web_name}'

    def keys(self):
        return 'web_name', 'web_key', 'web_description', 'web_all_key', 'web_domain', 'web_logo', 'web_QrCode', 'web_record', 'web_stat', 'web_company', 'web_contact_adders', 'web_contact_tel', 'web_contact_qq', 'web_contact_email', 'web_message', 'web_on_off', 'web_topBar'


class Ad_Model(BaseModel):
    ad_name = db.Column(db.String(255), comment='广告名称')
    ad_code = db.Column(db.Text, default='', comment='广告代码')
    ad_end_date = db.Column(db.Date, default=get_date(), comment='到期时间')
    ad_description = db.Column(db.Text, default='', comment='广告描述')

    def __repr__(self):
        return f'广告名称:{self.ad_name}'

    def keys(self):
        return 'ad_name', 'ad_code', 'ad_end_date', 'ad_description', 'status',


class Blogroll_Model(BaseModel):
    link_name = db.Column(db.String(255), comment='链接名称')
    link_url = db.Column(db.String(255), comment='链接地址')
    color = db.Column(db.String(64), comment='链接颜色')
    link_sort = db.Column(db.Integer, default=0, comment='链接排序')
    isbold = db.Column(db.Integer, default=1, comment='显示方式')

    def __repr__(self):
        return f'链接名称: {self.link_name}'

    def keys(self):
        return 'link_name', 'link_url', 'color', 'link_sort', 'isbold', 'status',


class Share_Modle(BaseModel):
    share_detail = db.Column(db.Text, default='', comment='详情分享')
    share_all = db.Column(db.Text, default='', comment='整站分享')

    def keys(self):
        return 'share_detail', 'share_all',


class API_Modle(BaseModel):
    api_key = db.Column(db.String(256), default='', comment='API-KEY')
    api_ak = db.Column(db.String(256), default='', comment='API-AK')

    def keys(self):
        return 'api_key', 'api_ak',


class Discuss_Model(BaseModel):
    discuss_code = db.Column(db.Text, default='', comment='评论代码')

    def keys(self):
        return 'discuss_code',


class Log_Model(BaseModel):
    detail_time = db.Column(db.String(52), comment='详细时间')
    content = db.Column(db.String(128), comment='日志内容')

    def keys(self):
        return 'detail_time', 'content',


class Accredit_Model(BaseModel):
    domain = db.Column(db.String(128),default='', comment='授权域名')
    accredit_code = db.Column(db.String(256),default='', comment='授权密钥')

    def __repr__(self):
        return f'授权域名:{self.domain}'

    def keys(self):
        return 'domain','accredit_code',